﻿using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using GameLibrary.Model;
using GameLibrary.Model.Play;
using Microsoft.VisualBasic.PowerPacks;
using GameLibrary.Model.Core;
using G.Model.Runtime;
using GameRuntimeLibrary.Model.Runtime;
using G.Runtime;

namespace GameDesigner.Source.Widgets
{
    class ScoreBoardPanel
    {
        private readonly GameDef _Game;
        private readonly SimpleShape _SimpleShape;
        private readonly List<BoundVariableWidget> _Widgets = new List<BoundVariableWidget>();
        private readonly List<GameValue> _BoundVariables = new List<GameValue>();

        public ScoreBoardPanel(Game pGame, SimpleShape control)
        {
            _Game = pGame.GameDef;
            _SimpleShape = control;
            int y = 5;
            if (pGame.Globals.Values.Contains(Constants.MOVES))
            {
                IntGameValue e = (IntGameValue)
                    pGame.Globals.Values[Constants.MOVES];
                _BoundVariables.Add(e);

                BoundVariableWidget w = new BoundVariableWidget(e, control);
                w.Point = new Point(5, y);
                _Widgets.Add(w);
                y += 20;
            }
            {
                _BoundVariables.Add(pGame.GameController.NameOfPlayerWithTurn);
                BoundVariableWidget w = new BoundVariableWidget(
                    pGame.GameController.NameOfPlayerWithTurn, control);
                w.Point = new Point(5, y);
                _Widgets.Add(w);
            }
        }

        public void OnPaint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Pen pen = new Pen(Color.LightGray, 1);
            foreach (BoundVariableWidget w in _Widgets)
            {
                w.Update(g);
            }
        }
    }
}
